local juwu = fk.CreateSkill{
    name = "wegame_2__juwu",
}
Fk:loadTranslationTable{
    ["wegame_2__juwu"] = "拒武",
    [":wegame_2__juwu"] = "中央区牌数为五的倍数的回合结束时，你置顶其中一张，然后当前回合角色可以视为对你使用从任意一端展示的【兵临城下】，若仍为五的倍数则重复此流程。",
    ["#wegame_2__juwu-card"] = "拒武：置顶其中一张牌",
    ["#wegame_2__juwu-use"] = "拒武：你可以视为对 %dest 使用从任意一端展示的【兵临城下】",
}

juwu:addEffect(fk.TurnEnd,{
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(juwu.name) and #player.room:getBanner("@$CenterArea") > 0 and #player.room:getBanner("@$CenterArea") % 5 == 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        while #room:getBanner("@$CenterArea") > 0 and #room:getBanner("@$CenterArea") % 5 == 0 do
            local card = room:askToChooseCard(player, {
                target = player,
                flag = { card_data = {{ "$CenterArea", room:getBanner("@$CenterArea") }} },
                skill_name = juwu.name,
                prompt = "#wegame_2__juwu-card",
            })
            room:moveCards {
                ids = { card },
                toArea = Card.DrawPile,
                moveReason = fk.ReasonJustMove,
                skillName = juwu.name,
                proposer = player,
                moveVisible = true,
            }

            if room.current and not room.current.dead then
                if room:askToSkillInvoke(player,{
                    skill_name = juwu.name,
                    prompt = "#wegame_2__juwu-use::"..player.id,
                }) then
                    room:useVirtualCard("enemy_at_the_gates", nil, room.current, {player}, juwu.name)
                end
            end
        end
    end,
})

juwu:addEffect(fk.PreCardEffect, {
    can_refresh = function (self, event, target, player, data)
        return target == player and data and data.card.trueName == "enemy_at_the_gates" and data.card.skillName == juwu.name
    end,
    on_refresh = function(self, event, target, player, data)
        local card = data.card:clone()
        local c = table.simpleClone(data.card)
        for k, v in pairs(c) do
            card[k] = v
        end
        card.skill = Fk.skills["wegame_2_juwu__enemy_at_the_gates_skill"]
        data.card = card
    end,
})

juwu:addAcquireEffect(function(self, player, is_start)
    player.room:addSkill("#CenterArea")
end)

return juwu